import { createSlice } from "@reduxjs/toolkit";

export const cangg = createSlice({
  name: "cang",
  initialState: {
    cang:[
            {
                id:'1',
                name:'张三',
                code:'34684563654'
            },
            {
                id:'2',
                name:'李四',
                code:'134534512671234'
            },
        ]
},
  reducers: {
    shanchu: (state, action) => {
        state.cang =state.cang.filter(v=>v.id!==action.payload)
      },
    tianjia:(state,action)=>{
        state.cang.push({
            ...action.payload,
            id:new Date().getTime()
        })
    }
  },
});

export const { shanchu ,tianjia} = cangg.actions;
